<!-- keywordsDefault -->
{{- $.Scratch.Delete "keywordsDefault" -}}
{{- range $taxonomy, $terms := .Site.Taxonomies -}}
    {{- range $term, $value := $terms -}}
        {{- $.Scratch.Add "keywordsDefault" (printf "%s, " ($term | anchorize)) -}}
    {{- end -}}
{{- end -}}
{{- if (eq $.Site.Params.categoryBy "sections") -}}
    {{- partial "components/tree-sections.html" . -}}
    {{ $sections := (split (strings.TrimSuffix ", " ($.Scratch.Get "sections")) ", ") }}
    {{- $.Scratch.Delete "sections" -}}
    {{- range $sections -}}
        {{- $section := . | anchorize -}}
        {{- $.Scratch.Add "sections" (slice $section) -}}
    {{- end -}}
    {{- $keywordsDefault := (replace (delimit (union (split (strings.TrimSuffix ", " ($.Scratch.Get "keywordsDefault")) ", ") ($.Scratch.Get "sections")) " ") " " ", ") -}}
    {{- $.Scratch.Set "keywordsDefault" $keywordsDefault -}}
{{- end -}}
<!-- keywordsSite -->
{{- $.Scratch.Delete "keywordsSite" -}}
{{- range .Site.Params.siteKeywords -}}
    {{- $.Scratch.Add "keywordsSite" (printf "%s, " .) -}}
{{- end -}}
<!-- keywordsPost -->
{{- $.Scratch.Delete "keywordsPost" -}}
{{- if .IsPage -}}
    {{- range $taxonomy, $terms := .Site.Taxonomies -}}
        {{- with $.Param $taxonomy -}}
            {{- range $index, $term := . -}}
                {{- $.Scratch.Add "keywordsPost" (printf "%s, " ($term | anchorize)) -}}
            {{- end -}}
        {{- end -}}
    {{- end -}}
    {{- with .Section -}}
        {{- if and (eq $.Site.Params.categoryBy "sections") (in $.Site.Params.mainSections $.Section) -}}
            {{- $.Scratch.Delete "Dir" -}}
            {{- $.Scratch.Delete "mainSections" -}}
            {{- $sections := split (strings.TrimSuffix "/" $.File.Dir) "/" -}}
            {{- range $sections -}}
                {{- $section := . -}}
                {{- $.Scratch.Add "Dir" (printf `/%s` $section) -}}
                {{- with $.Site.GetPage ($.Scratch.Get "Dir") -}}
                    {{- if (eq .Kind "section") -}}
                        {{- $.Scratch.Add "mainSections" (slice ($section | anchorize)) -}}
                    {{- end -}}
                {{- end -}}
            {{- end -}}
        {{- end -}}
    {{- end -}}
    {{- $keywordsPost := (replace (delimit (union (split (strings.TrimSuffix ", " ($.Scratch.Get "keywordsPost")) ", ") ($.Scratch.Get "mainSections")) " ") " " ", ") -}}
    {{- $.Scratch.Set "keywordsPost" $keywordsPost -}}
{{- end -}}
<!-- keywordsFrontMatter -->
{{- $.Scratch.Delete "keywordsFrontMatter" -}}
{{- range .Keywords -}}
    {{- $.Scratch.Add "keywordsFrontMatter" (printf "%s, " .) -}}
{{- end -}}